﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InputProductStore.aspx.cs"
    Inherits="Manager_ProductStore_InputProductStore" Title="Cập nhật kho" %>

<%@ Register Src="../../Pub/Module/Calendar_Submit.ascx" TagName="Calendar" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="../../Pub/Css/BodyStyles.css" rel="stylesheet" type="text/css" />
    <link href="../../Pub/Css/AdminStyles.css" rel="stylesheet" type="text/css" />
    <link href="../../Pub/Css/CalendarStyles.css" rel="stylesheet" type="text/css" />
    <link href="../../Pub/Css/calendar.css" rel="stylesheet" />
    <link href="../../Pub/Css/calendar.css" rel="stylesheet" />
    <link href="../../Pub/Css/calendar.css" rel="stylesheet" />
    <link href="../../Pub/Css/calendar.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
        <table border="1" cellpadding="2" cellspacing="2" class="tbl_Comon-Search" width="90%">
            <tr>
                <td class="td_Title" nowrap="nowrap" style="width: 150px; background-color: whitesmoke;">
                    Mã sản phẩm</td>
                <td class="td_Control">
                    <asp:Label ID="lblPDID" runat="server" ForeColor="Blue"></asp:Label></td>
            </tr>
            <tr>
                <td class="td_Title" nowrap="nowrap" style="width: 150px; background-color: whitesmoke;">
                    Tên sản phẩm</td>
                <td class="td_Control">
                    <asp:Label ID="lblPDNm" runat="server" Font-Bold="True" ForeColor="Blue"></asp:Label></td>
            </tr>
            <tr>
                <td class="td_Title" nowrap="nowrap" style="width: 150px; background-color: whitesmoke">
                    Giá bán ra</td>
                <td class="td_Control">
                    <asp:Label ID="lblPriceOut" runat="server" Font-Bold="True" ForeColor="Blue"></asp:Label>
                    <asp:Label ID="lblRateOut" runat="server" Font-Bold="True" ForeColor="DarkGreen"></asp:Label></td>
            </tr>
            <tr id="tr1" runat="server">
                <td class="td_Title" nowrap="nowrap" style="width: 120px">
                    Chọn Kho</td>
                <td class="td_Control">
                    <asp:DropDownList ID="ddlStore" runat="server" AutoPostBack="True" ValidationGroup="grbCheck"
                        OnSelectedIndexChanged="ddlStore_SelectedIndexChanged">
                    </asp:DropDownList>&nbsp; Số lượng:
                    <asp:Label ID="lblQuantity" runat="server" Font-Bold="True"></asp:Label>
                    <asp:Label ID="lblTotalStore" runat="server" Font-Bold="False" Visible="False"></asp:Label></td>
            </tr>
            <tr  id="tr2" runat="server">
                <td class="td_Title" nowrap="nowrap" style="width: 120px">
                    <asp:Label ID="lblTitleQuantity" runat="server" Text="Số lượng nhập kho"></asp:Label>
                </td>
                <td class="td_Control">
                    <asp:TextBox ID="txtInput" runat="server" Width="17%" ValidationGroup="grbCheck"
                        CssClass="txt_Product">0</asp:TextBox>&nbsp;
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtInput"
                        ErrorMessage="Nhập vào số lượng" ValidationGroup="grbCheck">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtInput"
                        ErrorMessage="Yêu cầu nhập đơn giá phải là số" ValidationExpression="^\d+$" ValidationGroup="grbCheck">*</asp:RegularExpressionValidator></td>
            </tr>
            <tr  id="tr4" runat="server">
                <td class="td_Title" nowrap="nowrap" style="width: 120px">
                    Giá gốc</td>
                <td class="td_Control" valign="middle">
                    <asp:TextBox ID="txtOriginalPrice" runat="server" CssClass="txt_Product" onkeyup="fnDisplayTextMoney(this)"
                        Text="0" ValidationGroup="GrpAdd" Width="120px"></asp:TextBox>
                    <asp:DropDownList ID="ddlOriginalRate" runat="server" CssClass="cssDropdownlist"
                        ForeColor="Purple">
                    </asp:DropDownList>
                    <uc1:Calendar ID="Calendar1" runat="server"/>
                </td>
            </tr> 
            <tr  id="tr3" runat="server">
                <td class="td_Title" nowrap="nowrap" style="width: 120px">
                    Ghi chú</td>
                <td class="td_Control">
                    <asp:TextBox ID="txtNote" runat="server" Height="81px" TextMode="MultiLine" Width="90%"
                        CssClass="txt_Product"></asp:TextBox></td>
            </tr>
           
            <tr>
                <td style="width: 120px">
                </td>
                <td>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                        ShowSummary="False" ValidationGroup="grbCheck" />
                </td>
            </tr>
            <tr>
                <td style="width: 120px">
                </td>
                <td>
                    <asp:Button ID="btnAdd_Catalogue" runat="server" CssClass="cssButton" OnClick="btnAdd_Catalogue_Click"
                        Text="Bảo lưu" ValidationGroup="grbCheck" CausesValidation="true" />
                    <asp:Button Visible="false" ID="btnReturn" runat="server" CssClass="cssButton" OnClick="btnReturn_Click"
                        Text="Quay lại" /></td>
            </tr>
        </table>
        <input type="hidden" id="hidSPDID" runat="server" />
        <input type="hidden" id="hidMethod" runat="server" />
    </form>

    <script language="javascript" type="text/javascript" src="../../Pub/Js/jquery.js"></script>
    
    <script language="javascript" type="text/javascript">
     function FormatMoney(number) 
 		        {
                    var thousandsSeparator = ',';

                    number = stripDollarSign(number);
                    number = isNaN(number) || number == '' || number == null ? 0 : number;
                    var numberStr = parseFloat(number).toFixed(2).toString();
                    var numberFormatted = new Array(numberStr.slice(-3));   // this returns the decimal and cents
                    numberStr = numberStr.substring(0, numberStr.length-3); // this removes the decimal and cents
                    /*
                     * Why is there an `unshift()` function, but no `shift()`?
                     * Also, a `pop()` function would be handy here.
                     */
                    while (numberStr.length > 3) {
                        numberFormatted.unshift(numberStr.slice(-3)); // this prepends the last three digits to `numberFormatted`
                        numberFormatted.unshift(thousandsSeparator); // this prepends the thousandsSeparator to `numberFormatted`
                        numberStr = numberStr.substring(0, numberStr.length-3);  // this removes the last three digits
                    }
                    numberFormatted.unshift(numberStr); // there are less than three digits in numberStr, so prepend them
                    return numberFormatted.join('').replace(".00",""); // put it all together
                }
                
                function stripDollarSign(s) {
                    if (typeof s == 'string') { s = s.replace(/\$/g, ''); }
                    return s;
                }

	            //ReplayAll
                String.prototype.ReplaceAll = function(stringToFind,stringToReplace)
                {
                    var temp = this;

                    var index = temp.indexOf(stringToFind);

                        while(index != -1){
                            temp = temp.replace(stringToFind,stringToReplace);
                            index = temp.indexOf(stringToFind);
                        }
                        return temp;
                   }
                  function fnDisplayTextMoney(obj)
                {
                    obj.value=FormatMoney(obj.value.ReplaceAll(",",""))   ; 
                }
               
               function fnSubmitCalendar(sDate) 
               {
                     $("#<%=hidMethod.ClientID %>").val("<Method>LoadCalendar</Method><Date>"+sDate+"</Date>");
                    document.forms["form1"].submit();
               }
             
 
    </script>

</body>
</html>
